home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / tcp_ip / tnos / tnos100s / ax25.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-29  |  8.7 KB  |  268 lines

  1.  /* Mods by G1EMM */
  2. #ifndef    _AX25_H
  3. #define    _AX25_H
  4.  
  5. #ifndef    _GLOBAL_H
  6. #include "global.h"
  7. #endif
  8.  
  9. #ifndef _IP_H
  10. #include "ip.h"
  11. #endif
  12.  
  13. #ifndef    _MBUF_H
  14. #include "mbuf.h"
  15. #endif
  16.  
  17. #ifndef    _IFACE_H
  18. #include "iface.h"
  19. #endif
  20.  
  21. #ifndef    _SOCKADDR_H
  22. #include "sockaddr.h"
  23. #endif
  24.  
  25. /* AX.25 datagram (address) sub-layer definitions */
  26.  
  27. #define    MAXDIGIS    7    /* Maximum number of digipeaters */
  28. #define    ALEN        6    /* Number of chars in callsign field */
  29. #define    AXALEN        7    /* Total AX.25 address length, including SSID */
  30. #define    AXBUF        10    /* Buffer size for maximum-length ascii call */
  31.  
  32. #ifndef _LAPB_H
  33. #include "lapb.h"
  34. #endif
  35.  
  36. /* Bits within SSID field of AX.25 address */
  37. #define    SSID        0x1e    /* Sub station ID */
  38. #define    REPEATED    0x80    /* Has-been-repeated bit in repeater field */
  39. #define    E        0x01    /* Address extension bit */
  40. #define    C        0x80    /* Command/response designation */
  41.  
  42. /* Our AX.25 address */
  43. extern char Mycall[AXALEN];
  44.  
  45. /* List of AX.25 multicast addresses, e.g., "QST   -0" in shifted ASCII */
  46. extern char Ax25multi[][AXALEN];
  47. #define QSTCALL 0
  48. #define NODESCALL 1
  49. #define MAILCALL 2
  50. #define IDCALL 3
  51. /*currently not used in this code*/
  52. #define OPENCALL 4
  53. #define CQCALL 5
  54. #define BEACONCALL 6
  55. #define RMNCCALL 7
  56. #define ALLCALL 8
  57.  
  58. extern int Digipeat;
  59. extern int Ax25mbox;
  60.  
  61. /* Number of chars in interface field. The involved definition takes possible
  62.  * alignment requirements into account, since ax25_addr is of an odd size.
  63.  */
  64. #define    ILEN    (sizeof(struct sockaddr) - sizeof(short) - AXALEN)
  65.  
  66. /* Socket address, AX.25 style */
  67. struct sockaddr_ax {
  68.     short sax_family;        /* 2 bytes */
  69.     char ax25_addr[AXALEN];
  70.     char iface[ILEN];        /* Interface name */
  71. };
  72.  
  73. /* Internal representation of an AX.25 header */
  74. struct ax25 {
  75.     char dest[AXALEN];        /* Destination address */
  76.     char source[AXALEN];        /* Source address */
  77.     char digis[MAXDIGIS][AXALEN];    /* Digi string */
  78.     int ndigis;            /* Number of digipeaters */
  79.     int nextdigi;            /* Index to next digi in chain */
  80.     int cmdrsp;            /* Command/response */
  81. };
  82.  
  83. /* C-bit stuff */
  84. #define    LAPB_UNKNOWN        0
  85. #define    LAPB_COMMAND        1
  86. #define    LAPB_RESPONSE        2
  87.  
  88. /* AX.25 routing table entry */
  89. struct ax_route {
  90.     struct ax_route *next;        /* Linked list pointer */
  91.     char target[AXALEN];
  92.     struct iface *iface;
  93.     char digis[MAXDIGIS][AXALEN];
  94.     int ndigis;
  95.     char type;
  96. #define    AX_LOCAL    1        /* Set by local ax25 route command */
  97. #define    AX_AUTO        2        /* Set by incoming packet */
  98.     char mode;            /* Connection mode (G1EMM) */
  99. #define    AX_DEFMODE    0        /* Use default interface mode */
  100. #define    AX_VC_MODE    1        /* Try to use Virtual circuit */
  101. #define    AX_DATMODE    2        /* Try to use Datagrams only */
  102. };
  103. #define NULLAXR    ((struct ax_route *)0)
  104.  
  105. extern struct ax_route *Ax_routes;
  106. extern struct ax_route Ax_default;
  107.  
  108. /* AX.25 Level 3 Protocol IDs (PIDs) */
  109. #define PID_X25        0x01    /* CCITT X.25 PLP */
  110. #define    PID_SEGMENT    0x08    /* Segmentation fragment */
  111. #define PID_TEXNET    0xc3    /* TEXNET datagram protocol */
  112. #define    PID_LQ        0xc4    /* Link quality protocol */
  113. #define    PID_APPLETALK    0xca    /* Appletalk */
  114. #define    PID_APPLEARP    0xcb    /* Appletalk ARP */
  115. #define    PID_IP        0xcc    /* ARPA Internet Protocol */
  116. #define    PID_ARP        0xcd    /* ARPA Address Resolution Protocol */
  117. #define    PID_RARP    0xce    /* ARPA Reverse Address Resolution Protocol */
  118. #define    PID_NETROM    0xcf    /* NET/ROM */
  119. #define    PID_NO_L3    0xf0    /* No level 3 protocol */
  120.  
  121. #define    SEG_FIRST    0x80    /* First segment of a sequence */
  122. #define    SEG_REM        0x7f    /* Mask for # segments remaining */
  123.  
  124. #define    AX_EOL        "\r"    /* AX.25 end-of-line convention */
  125.  
  126. /* Link quality report packet header, internal format */
  127. struct lqhdr {
  128.     int16 version;        /* Version number of protocol */
  129. #define    LINKVERS    1
  130.     int32    ip_addr;    /* Sending station's IP address */
  131. };
  132. #define    LQHDR    6
  133. /* Link quality entry, internal format */
  134. struct lqentry {
  135.     char addr[AXALEN];    /* Address of heard station */
  136.     int32 count;        /* Count of packets heard from that station */
  137. };
  138. #define    LQENTRY    11
  139.  
  140. /* Link quality database record format
  141.  * Currently used only by AX.25 interfaces
  142.  */
  143. struct lq {
  144.     struct lq *next;
  145.     char addr[AXALEN];    /* Hardware address of station heard */
  146.     struct iface *iface;    /* Interface address was heard on */
  147.     int32 time;        /* Time station was last heard */
  148.     int32 currxcnt;    /* Current # of packets heard from this station */
  149.  
  150. #ifdef    notdef        /* Not yet implemented */
  151.     /* # of packets heard from this station as of his last update */
  152.     int32 lastrxcnt;
  153.  
  154.     /* # packets reported as transmitted by station as of his last update */
  155.     int32 lasttxcnt;
  156.  
  157.     int16 hisqual;    /* Fraction (0-1000) of station's packets heard
  158.              * as of last update
  159.              */
  160.     int16 myqual;    /* Fraction (0-1000) of our packets heard by station
  161.              * as of last update
  162.              */
  163. #endif
  164. };
  165. #define    NULLLQ    (struct lq *)0
  166.  
  167. extern struct lq *Lq;    /* Link quality record headers */
  168.  
  169. /* Structure used to keep track of monitored destination addresses */
  170. struct ld {
  171.     struct ld *next;    /* Linked list pointers */
  172.     char addr[AXALEN];/* Hardware address of destination overheard */
  173.     struct iface *iface;    /* Interface address was heard on */
  174.     int32 time;        /* Time station was last mentioned */
  175.     int32 currxcnt;    /* Current # of packets destined to this station */
  176. };
  177. #define    NULLLD    (struct ld *)0
  178.  
  179. extern struct ld *Ld;    /* Destination address record headers */
  180.  
  181. /* Linkage to network protocols atop ax25 */
  182. struct axlink {
  183.     int pid;
  184.     void (*funct) __ARGS((struct iface *,struct ax25_cb *,char *, char *,
  185.      struct mbuf *,int));
  186. };
  187. extern struct axlink Axlink[];
  188.  
  189. /* Codes for the open_ax25 call */
  190. #define    AX_PASSIVE    0
  191. #define    AX_ACTIVE    1
  192. #define    AX_SERVER    2    /* Passive, clone on opening */
  193.  
  194. /* Max number of fake AX.25 interfaces for RFC-1226 encapsulation */
  195. #define NAX25       16
  196.  
  197. #define    AXHEARD_PASS    0    /* Log both src and dest callsigns */
  198. #define    AXHEARD_NOSRC    1    /* do not log source callsign */
  199. #define    AXHEARD_NODST    2    /* do not log destination callsign */
  200. #define    AXHEARD_NONE    3    /* do not log any callsign */
  201.  
  202. /* an call that should not be jump-started */
  203. struct no_js {
  204.     struct no_js *next;
  205.     char call[AXALEN];
  206. };
  207.  
  208. /* In ax25.c: */
  209. struct ax_route *ax_add __ARGS((char *,int,char digis[][AXALEN],int,struct iface *));
  210. int ax_drop __ARGS((char *,struct iface *));
  211. struct ax_route *ax_lookup __ARGS((char *,struct iface *));
  212. void axip_input __ARGS((struct iface *iface,struct ip *ip,struct mbuf *bp,int rxbroadcast));
  213. void ax_recv __ARGS((struct iface *,struct mbuf *));
  214. int ax_send __ARGS((struct mbuf *bp,struct iface *iface,int32 gateway,int prec,
  215.     int del,int tput,int rel));
  216. int ax_output __ARGS((struct iface *iface,char *dest,char *source,int16 pid,
  217.     struct mbuf *data));
  218. int sendframe __ARGS((struct ax25_cb *axp,int cmdrsp,int ctl,struct mbuf *data));
  219. void axnl3 __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  220.     char *dest,struct mbuf *bp,int mcast));
  221.  
  222. /* In ax25cmd.c: */
  223. void st_ax25 __ARGS((struct ax25_cb *axp));
  224. int axheard __ARGS((struct iface *ifp));
  225.  
  226. /* In axhdr.c: */
  227. struct mbuf *htonax25 __ARGS((struct ax25 *hdr,struct mbuf *data));
  228. int ntohax25 __ARGS((struct ax25 *hdr,struct mbuf **bpp));
  229.  
  230. /* In axlink.c: */
  231. void getlqentry __ARGS((struct lqentry *ep,struct mbuf **bpp));
  232. void getlqhdr __ARGS((struct lqhdr *hp,struct mbuf **bpp));
  233. void logsrc __ARGS((struct iface *iface,char *addr));
  234. void logdest __ARGS((struct iface *iface,char *addr));
  235. char *putlqentry __ARGS((char *cp,char *addr,int32 count));
  236. char *putlqhdr __ARGS((char *cp,int16 version,int32 ip_addr));
  237. struct lq *al_lookup __ARGS((struct iface *ifp,char *addr,int sort));
  238.  
  239. /* In ax25user.c: */
  240. int ax25val __ARGS((struct ax25_cb *axp));
  241. int disc_ax25 __ARGS((struct ax25_cb *axp));
  242. int kick_ax25 __ARGS((struct ax25_cb *axp));
  243. struct ax25_cb *open_ax25 __ARGS((struct iface *,char *,char *,
  244.     int,int16,
  245.     void (*) __ARGS((struct ax25_cb *,int)),
  246.     void (*) __ARGS((struct ax25_cb *,int)),
  247.     void (*) __ARGS((struct ax25_cb *,int,int)),
  248.     int user));
  249. struct mbuf *recv_ax25 __ARGS((struct ax25_cb *axp,int16 cnt));
  250. int reset_ax25 __ARGS((struct ax25_cb *axp));
  251. int send_ax25 __ARGS((struct ax25_cb *axp,struct mbuf *bp,int pid));
  252.  
  253. /* In ax25subr.c: */
  254. int addreq __ARGS((char *a,char *b));
  255. struct ax25_cb *cr_ax25 __ARGS((char *local,char *remote,struct iface *iface));
  256. void del_ax25 __ARGS((struct ax25_cb *axp));
  257. struct ax25_cb *find_ax25 __ARGS((char *local,char *remote,struct iface *iface));
  258. char *pax25 __ARGS((char *e,char *addr));
  259. int setcall __ARGS((char *out,char *call));
  260.  
  261. /* In socket.c: */
  262. void beac_input __ARGS((struct iface *iface,char *src,struct mbuf *bp));
  263. void s_arcall __ARGS((struct ax25_cb *axp,int cnt));
  264. void s_ascall __ARGS((struct ax25_cb *axp,int old,int new));
  265. void s_atcall __ARGS((struct ax25_cb *axp,int cnt));
  266.  
  267. #endif    /* _AX25_H */
  268.